package com.whw.cbf_qimodazuoye.activity;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.text.TextPaint;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.whw.cbf_qimodazuoye.R;
import com.whw.cbf_qimodazuoye.entity.GlideImageLoader;
import com.whw.cbf_qimodazuoye.utils.DaysUtil;
import com.whw.cbf_qimodazuoye.utils.OrderUtil;
import com.youth.banner.Banner;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;


public class HotelActivity extends AppCompatActivity {
    private List<String> carouseUrllList = new LinkedList<>();
    List<String> RuZhuriqi = new LinkedList<>();
    List<String> LiKairiqi = new LinkedList<>();
    private TextView txtDate1;
    private Button btnDate1;
    private TextView txtDate2;
    private Button btnDate2;
    private Button btnBooking;
    DateFormat format= DateFormat.getDateTimeInstance();
    Calendar calendar= Calendar.getInstance(Locale.CHINA);
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_hotel_xiangxi);
        Bundle bundle = this.getIntent().getExtras();
        final String hotelCoverpic = bundle.getString("hotelCoverpic");
        final String hotelIndexpic = bundle.getString("hotelIndexpic");
        final String hotelName = bundle.getString("hotelName");
        final String hotelIndex = bundle.getString("hotelIndex");
        final String hotelPrice = bundle.getString("hotelPrice");
        final String hotelId = bundle.getString("HotelId");
        final String hotelLabel = bundle.getString("hotelLabel");
        final String hotelNumber = bundle.getString("hotelNumber");
        final String userId = bundle.getString("userId");
        final String userIntegral = bundle.getString("userIntegral");
        final String userName = bundle.getString("userName");

        TextView hotelNameView = (TextView)findViewById(R.id.hotelName);
        TextPaint paint1 = hotelNameView.getPaint();
        paint1.setFakeBoldText(true);

        TextView hotelPriceView = (TextView)findViewById(R.id.hotelPrice);
        TextPaint paint2 = hotelPriceView.getPaint();
        paint2.setFakeBoldText(true);

        TextView hotelIndexView = (TextView)findViewById(R.id.hotelIndex);
        TextPaint paint3 = hotelIndexView.getPaint();
        paint3.setFakeBoldText(true);

        TextView hotelNumberView = (TextView)findViewById(R.id.hotelNumber);
        TextPaint paint4 = hotelNumberView.getPaint();
        paint4.setFakeBoldText(true);

        TextView hotelLabelView = (TextView)findViewById(R.id.hotelLabel);
        TextPaint paint5 = hotelLabelView.getPaint();
        paint5.setFakeBoldText(true);

        hotelLabelView.setText(hotelLabel);
        hotelNumberView.setText(hotelNumber);
       hotelNameView.setText(hotelName);
        hotelPriceView.setText(hotelPrice);
        hotelIndexView.setText(hotelIndex);
        initHotelCarouse(hotelIndexpic);

        BottomNavigationView navView = findViewById(R.id.nav_view);
        // Passing each menu ID as a set of Ids because each
        // menu should be considered as top level destinations.
        AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
                R.id.navigation_home,  R.id.navigation_notifications)
                .build();
        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
        NavigationUI.setupWithNavController(navView, navController);
        navView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                switch (item.getItemId()) {
                    case R.id.navigation_home:
                        /**
                         * Intent intent=new Intent(MainActivity.this,MainActivity.class);
                         *                         startActivity(intent);
                         */

                        return true;

                    case R.id.navigation_notifications:
                    {
                        Bundle bundle = new Bundle();
                        bundle.putString("userId",userId);
                        bundle.putString("userName",userName);
                        bundle.putString("userIntegral",userIntegral);
                        Intent intent=new Intent(HotelActivity.this,MineActity.class);
                        intent.putExtras(bundle);
                        startActivity(intent);
                        return true;
                    }
                    case R.id.navigation_dashboard:{
                        Bundle bundle = new Bundle();
                        bundle.putString("userId",userId);
                        bundle.putString("userName",userName);
                        bundle.putString("userIntegral",userIntegral);
                        Intent intent=new Intent(HotelActivity.this,RecommendationActivity.class);
                        intent.putExtras(bundle);
                        startActivity(intent);
                        return true;
                    }
                }
                return false;
            }
        });

        btnBooking= (Button) findViewById(R.id.order);
        btnBooking.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Bundle bundle = new Bundle();
                bundle.putString("userId",userId);
                bundle.putString("userName",userName);
                bundle.putString("userIntegral",userIntegral);
                bundle.putString("hotelId",hotelId);
                bundle.putString("hotelPrice",hotelPrice);
                bundle.putString("hotelName",hotelName);
                bundle.putString("hotelIndex",hotelIndex);
                bundle.putString("hotelCoverpic",hotelCoverpic);
                bundle.putString("hotelIndexpic",hotelIndexpic);
                bundle.putString("hotelNumber",hotelNumber);
                bundle.putString("hotelLabel",hotelLabel);
                Intent intent=new Intent(HotelActivity.this,OrderActivity.class);
                intent.putExtras(bundle);
                startActivity(intent);
            }
        });
    }



    private void initHotelCarouse(String hotelIndexPic){
        String pics[] = hotelIndexPic.split(";");
        for(String pic:pics){
            carouseUrllList.add(pic);
        }
        Banner banner = findViewById(R.id.hotelbanner);
        banner.setImageLoader(new GlideImageLoader());   //设置图片加载器
        banner.setImages(carouseUrllList);  //设置banner中显示图片
        banner.start();  //设置完毕后调用
    }






}
